﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Table.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	用户管理
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>用户列表</h2>
    <p><%: Html.ActionLink("添加新用户", "NewUser") %></p>
    <div id="tparent" style="width:100%;overflow:auto;">
    <script type="text/javascript">
        //alert($("#tparent").parent().width());
        $("#tparent").css("width", $("#tparent").parent().width());
    </script>
    <table style="white-space:nowrap;">
        <tr>
            <%
                string[] headers = "用户编号,用户名称,登录密码,操作权限,备注,操作".Split(new char[] { ',' });
                for (int i = 0; i < headers.Length; i++) {
                    Response.Write("<th>" + headers[i] + "</th>");
                }
            %>
        </tr>
        <%
            List<SohuWeb.Models.User> list = (List<SohuWeb.Models.User>)ViewData["UserList"];
            for (int i = 0; i < list.Count; i++) {
                Response.Write("<tr>");
                Response.Write(string.Format("<td>{0:D}</td>", list[i].uid));
                Response.Write(string.Format("<td>{0}</td>", list[i].username));
                Response.Write(string.Format("<td>{0}</td>", list[i].password));
                switch (list[i].level) {
                    case 0:
                        Response.Write(string.Format("<td>{0}</td>", "ES普通人员"));
                        break;
                    case 1:
                        Response.Write(string.Format("<td>{0}</td>", "ES管理员"));
                        break;
                    case 2:
                        Response.Write(string.Format("<td>{0}</td>", "超级管理员"));
                        break;
                    default:
                        break;
                }
                Response.Write(string.Format("<td>{0}</td>", list[i].memo));
                string opt = string.Format("<td><input type='button' value='删除' onclick='if(confirm(\"确定要删除用户[{0}]吗？\"))location.href=\"/Account/DeleteUser?uid={1}\";' /></td>", list[i].username, list[i].uid);
                Response.Write(opt);
                Response.Write("</tr>");
            }
         %>
    </table>
    </div>

</asp:Content>
